package com.denlaku.longan.controller.impl;

import com.denlaku.longan.controller.ApiCurrentController;
import com.denlaku.longan.core.Current;
import com.denlaku.longan.core.CurrentInfo;
import com.denlaku.longan.core.RequestContext;
import com.denlaku.longan.http.Resp;
import com.denlaku.longan.http.Return;
import com.denlaku.longan.vo.Tenant;
import com.denlaku.longan.vo.User;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tianx
 */
@RestController
public class ApiCurrentControllerImpl implements ApiCurrentController {
    @Override
    public Return<CurrentInfo> get() {
        CurrentInfo info = new CurrentInfo();
        RequestContext current = Current.getCurrent();
        Tenant tenant = current.getTenant();
        if (tenant != null) {
            info.setTenantName(tenant.getName());
        }
        User user = current.getUser();
        if (user != null) {
            info.setUserName(user.getName());
        }
        return Resp.success(info);
    }
}
